/**
* This file is part of OntoApplications (project linked with OntoCompoFramework)
*
* Copyright (C) 2011 -  Christian Brel
*
* @author   Main    Christian Brel
**/
package applications.businessdirectory.fc.lib;

import java.util.Observable;

import ontocompo.api.OntoCompoIntrospection;

import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Interface;

import applications.businessdirectory.fc.api.Assignment;
import applications.businessdirectory.fc.api.BusinessCard;
import applications.businessdirectory.fc.api.BusinessDirectoryService;
import applications.businessdirectory.fc.api.Post;
import applications.businessdirectory.fc.api.Adress;
import applications.businessdirectory.fc.lib.AdressImpl;

@Component(provides = {@Interface(name = "businessdirectoryservice", signature = applications.businessdirectory.fc.api.BusinessDirectoryService.class), @Interface(name = "observable", signature = ontocompo.api.Observable.class), @Interface(name = "ontocompointrospection", signature = ontocompo.api.OntoCompoIntrospection.class)})
public class BusinessDirectoryServiceImpl extends Observable implements BusinessDirectoryService, ontocompo.api.Observable, OntoCompoIntrospection {

	private String employeeName;
	
	private String uid;
	private org.objectweb.fractal.api.Component c;
	
	public BusinessDirectoryServiceImpl() {
		this.uid = "applications.businessdirectory.fc.lib.BusinessDirectoryServiceImpl";
	}
	
	public void setEmployeeName(String employeeName) {
		this.employeeName = employeeName;
		setChanged();
		notifyObservers();
	}
	
	@Override
	public BusinessCard getBusinessCard() {
		// TODO Auto-generated method stub
		
		System.out.println("LE BUSINESS DIRECTORY SERVICE TRAVAILLE AVEC L'ENTREE SUIVANTE: " + this.employeeName);
		
		Post[] posts = new Post[]{ new PostImpl("Department Manager, Web Site Project") };
		
		Adress addr1 = new AdressImpl("9 rue des dames", "75009 PARIS", "FRANCE");
		Assignment a1 = new AssignmentImpl("Web Site Project", "B 455", "BATIMENT MATISSE", addr1,"+33 01 23 45 67 89", "56789", "");
		
		Adress addr2 = new AdressImpl("9 rue des dames", "75009 PARIS", "FRANCE");
		Assignment a2 = new AssignmentImpl("Executive Board", "C 2412", "BATIMENT CHAGALL", addr2,"+33 01 23 45 32 10", "53210", "");
		
		Assignment[] assignments = new Assignment[] {a1, a2};
		
		BusinessCard bc = new BusinessCardImpl("Ph D.", "John Peter Doe", "Visit Card", "John.Doe@jordan.com", posts, assignments);
		
		return bc;
	}

	public void clearChanged() {
		super.clearChanged();
	}
	
	public void setChanged() {
		super.setChanged();
	}

	@Override
	public org.objectweb.fractal.api.Component getFractalComponent() {
		// TODO Auto-generated method stub
		return this.c;
	}

	@Override
	public void setFractalComponent(org.objectweb.fractal.api.Component c) {
		// TODO Auto-generated method stub
		this.c = c;
	}
	
	@Override
	public String getUid() {
		// TODO Auto-generated method stub
		return this.uid;
	}

	@Override
	public void setUid(String uid) {
		// TODO Auto-generated method stub
		this.uid = uid;
	}
}
